import java.util.Scanner;
public class Three {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt(),m= in.nextInt();
        char[][] arr=new char[n+1][m+1];
        for (int i = 1; i <=n; i++) {
            char[] s=in.next().toCharArray();
            for (int j = 1; j <=m ; j++) {
                arr[i][j]=s[j-1];
            }
        }
        int[][] dp=new int[n+1][m+1];
        for (int i = 1; i <=n ; i++) {
            for (int j = 1; j <=m ; j++) {
                int t=0;
                if(arr[i][j]=='l') {
                    t = 4;
                } else if (arr[i][j]=='o') {
                    t = 3;
                }else if (arr[i][j]=='v') {
                    t = 2;
                }else if (arr[i][j]=='e') {
                    t = 1;
                }
                dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1])+t;
            }
        }
        System.out.println(dp[n][m]);
    }
}
